﻿using System;
using CookComputing.XmlRpc;

namespace hellaSharp
{
    public interface IHella : IXmlRpcProxy

    {
        [XmlRpcMethod("status")]
        XmlRpcStruct Status();

        [XmlRpcMethod("pause")]
        XmlRpcStruct Pause();

        [XmlRpcMethod("continue")]
        XmlRpcStruct Continue();

        [XmlRpcMethod("force")]
        XmlRpcStruct Force(int nzbID);

        [XmlRpcMethod("dequeue")]
        void Dequeue(int nzbID);

        [XmlRpcMethod("down")]
        void Down(int nzbID, int amount);

        [XmlRpcMethod("up")]
        void Up(int nzbID, int amount);

        [XmlRpcMethod("cancel")]
        void Cancel();

        [XmlRpcMethod("enqueueurl")]
        void EnqueueURL(String URL);

        [XmlRpcMethod("enqueuenewzbin")]
        XmlRpcStruct EnqueueNewzbin(String ID);
    }
    public class HellaSharp
    {
        private IHella hellaProxy;

        public HellaSharp(string url, string pass)
        {
            hellaProxy = XmlRpcProxyGen.Create<IHella>();
            hellaProxy.Url = url;
            hellaProxy.Credentials = new System.Net.NetworkCredential("hellanzb", pass);

        }

        public HellaSharp(string url, string user, string pass)
        {
            hellaProxy = XmlRpcProxyGen.Create<IHella>();
            hellaProxy.Url = url;
            hellaProxy.Credentials = new System.Net.NetworkCredential(user, pass);

        }

        public XmlRpcStruct Status()
        {
            return hellaProxy.Status();
        }
        public void Pause()
        {
            hellaProxy.Pause();
        }
        public void Continue()
        {
            hellaProxy.Continue();
        }
        public XmlRpcStruct Force(int Id)
        {
            return hellaProxy.Force(Id);
        }
        public void Dequeue(int Id)
        {
            hellaProxy.Dequeue(Id);
        }
        public void Up(int Id, int Amount)
        {
            hellaProxy.Up(Id, Amount);
        }
        public void Down(int Id, int Amount)
        {
            hellaProxy.Down(Id, Amount);
        }
        public void Up(int Id)
        {
            hellaProxy.Up(Id, 1);
        }
        public void Down(int Id)
        {
            hellaProxy.Down(Id, 1);
        }
        public void EnqueueURL(string Url)
        {
            hellaProxy.EnqueueURL(Url);
        }
        public XmlRpcStruct EnqueueUrl(string Id)
        {
           return hellaProxy.EnqueueNewzbin(Id);                
        }
    }
}
